package dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class VoteDAO {

	public List<String> getAllVotes() {
		ArrayList<String> votes = new ArrayList<String>();
		try {
			Connection connection = DBConnection.getDefaultConnection();
			Statement statement = connection.createStatement();

			String query = "SELECT vote FROM user";

			ResultSet rs = statement.executeQuery(query);

			while (rs.next()) {
				String vote = rs.getString("vote");
				if (vote != null) {
					votes.add(vote);
				}
			}
			rs.close();
			statement.close();
			DBConnection.closeConnection(connection);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			return votes;
		}
	}
}
